<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
header("Content-type:text/html;charset=gbk"); 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Cache-Control: no-cache, must-revalidate");   
header("Pragma: no-cache");
date_default_timezone_set('Etc/GMT-8');

define('KS_ROOT', str_replace("\\", '/', substr(dirname(__FILE__), 0, -3)));
define('MICROTIME_START', microtime());
define('IN_KS', TRUE);
define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
define('TIME', time());
set_magic_quotes_runtime(0);
set_time_limit(0);
require 'config.inc.php';
require 'db.class.php';
require 'global.func.php';


define('QUERY_STRING', $_SERVER['QUERY_STRING']);
define('PATH_INFO', isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '');
define('DOMAIN', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : preg_replace("/([^:]*)[:0-9]*/i", "\\1", $_SERVER['HTTP_HOST']));
define('SCHEME', $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://');
define('SITE_URL', SCHEME.$_SERVER['HTTP_HOST'].KS_PATH);
define('RELATE_URL', str_replace(array('(', '$', ')', '{', '}', '<', '>'), '', isset($_SERVER['REQUEST_URI']) ? (MAGIC_QUOTES_GPC ? new_stripslashes($_SERVER['REQUEST_URI']) : new_addslashes($_SERVER['REQUEST_URI'])) : SCRIPT_NAME.(QUERY_STRING ? '?'.QUERY_STRING : PATH_INFO)));
define('URL', SCHEME.$_SERVER['HTTP_HOST'].RELATE_URL);
define('RELATE_REFERER',urlencode(RELATE_URL));

$db = new db_mysql();
$db->connect(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_PCONNECT, DB_CHARSET);

session_start();


session_set_cookie_params(0, COOKIE_PATH, COOKIE_DOMAIN);

if($_REQUEST)
{
	if(MAGIC_QUOTES_GPC)
	{
		$_REQUEST = new_stripslashes($_REQUEST);
		if($_COOKIE) $_COOKIE = new_stripslashes($_COOKIE);
	}
	else
	{
		$_POST = new_addslashes($_POST);
		$_GET = new_addslashes($_GET);
		$_COOKIE = new_addslashes($_COOKIE);
		@extract($_POST);
		@extract($_GET);
		@extract($_COOKIE);
	}

	extract($db->escape($_REQUEST), EXTR_SKIP);
	if($_COOKIE) $db->escape($_COOKIE);
}
if(QUERY_STRING && strpos(QUERY_STRING, '=') === false && preg_match("/^(.*)\.(htm|html|shtm|shtml)$/", QUERY_STRING, $urlvar))
{
	parse_str(str_replace(array('/', '-', ' '), array('&', '=', ''), $urlvar[1]));
}

$page = $page ? intval($page) : 1;
$pagesize = 20;
?>